package cpa.prowon.gui;

import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.graphics.Image;

import cpa.prowon.gui.util.ImageUtil;
import cpa.prowon.image.ImageContainer;

/**
 * The picture list label provider provides the images and labels to display
 * the detailed picture information
 * @author Chris
 */
public class PictureListLabelProvider implements ITableLabelProvider {

	/**
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(Object, int)
	 */
	public Image getColumnImage(Object element, int column_index) {
		
		// By default return the picture icon
		if (column_index == 0)
		{
			if (((ImageContainer)element).canBeChanged())
			{
				return ImageUtil.getImage("icons/picture.gif");
			}
			else
			{
				return ImageUtil.getImage("icons/picture_ro.gif");				
			}
		}
		return null;
		
	}

	/**
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(Object, int)
	 */
	public String getColumnText(Object obj, int i) {

		ImageContainer ic = (ImageContainer) obj;

		switch (i)
		{
			case 0:
			String title = ic.getTitle();
			if (title != "")
			{
				return title;
			}
			return ic.getFileName();
			case 1:
			return ic.getCategory();
			case 2:
				return ic.getDate();
			}
			return "";
	}

	/**
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(ILabelProviderListener)
	 */
	public void addListener(ILabelProviderListener arg0) {
	}

	/**
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
	 */
	public void dispose() {
	}

	/**
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(Object, String)
	 */
	public boolean isLabelProperty(Object arg0, String arg1) {
		return false;
	}

	/**
	 * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(ILabelProviderListener)
	 */
	public void removeListener(ILabelProviderListener arg0) {
	}

}
